package com.yanqu.road.server.cmd.union.cross;

import com.yanqu.road.entity.player.CrossUserBaseInfo;
import com.yanqu.road.pb.union.UnionProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.union.CrossUnionMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;

@Cmd(code = Protocol.C_UNION_SET_FLAG_READ,desc = "读会旗")
public class CrossReadUnionFlagCmd extends CrossCommand {


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        UnionProto.ReadUnionFalgReq flagReq = UnionProto.ReadUnionFalgReq.parseFrom(packet.getBytes());
        CrossUserBaseInfo baseInfo = CrossUserMgr.getCrossUserBaseInfo(packet.getPlayerId());
        if(baseInfo != null){
            String unionUid = baseInfo.getUserBaseInfo().getUnionUid();
            if(!StringUtils.isNullOrEmpty(unionUid)){
                CrossUnionMgr.readUnionFlag(unionUid, new ArrayList<>(flagReq.getFlagIdList()));
            }
        }
    }

    @Override
    public void sendData() {

    }
}
